<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yuan1994 <tianpian0805@gmail.com>
 * @link http://tpadmin.yuan1994.com/
 * @copyright 2016 yuan1994 all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */

//------------------------
// 用户验证器
//-------------------------

namespace app\common\validate;

use think\Validate;

class AdminUser extends Validate
{
    protected $rule = [
        "realname" => "require",
        "account"  => "require|unique:admin_user",
        'password'=>'require|max:25',
        'repassword'=>'require|confirm:password',
        'code'=>'require',
        'mobile'  => 'require|regex:^1[34578]\d{9}$'
    ];
    // 当前验证场景
    protected $currentScene = "default";

    protected $message  =   [
        'realname.require' => '姓名必须',
        'account.require' => '账户必须',
        'account.unique'   => '账户已存在',
        'password.require'   => '请输入密码',
        'password.max'   => '密码过长',
        'repassword.require'   => '请输入确认密码',
        'repassword.confirm'   => '两次密码输入不一致',
        'code.require'   => '请输入确认验证码',
        'mobile.reqire' => '请输入手机号',
        'mobile.regex' => '请输入正确的手机号',
        'user_id.reqire' => '请输入正确的手机号',
    ];

    protected $scene = [
        'default'  =>  ['account','realname'],
        'register'  =>  ['account','password','repassword','code'],
        'updatepwd'  =>  ['account' => "require",'password','repassword','code'],
        'login'  =>  ['account'=>"require",'password'],
        'updatephone' => ['code','mobile','user_id'],
    ];
}
